using System;
using System.Collections.Generic;
using System.Text;
using Irc.Objects;

namespace Irc
{
	class ModeMap
	{
		private static ModeMap instance = new ModeMap();
		public static ModeMap Instance { get { return instance; } }
		public Dictionary<ModeName, char> ModeToCharTable = new Dictionary<ModeName, char>();
		public Dictionary<ModeName, char> ModeToSymbolTable = new Dictionary<ModeName, char>();
		public Dictionary<char, ModeName> SymbolToModeTable = new Dictionary<char,ModeName>();
		public Dictionary<char, ModeName> CharToModeTable = new Dictionary<char, ModeName>();
		private ModeMap() {
			// ModeToSymbolTable inits
			ModeToSymbolTable[ModeName.Owner]		= '~';
			ModeToSymbolTable[ModeName.Protected]	= '&';
			ModeToSymbolTable[ModeName.Operator]	= '@';
			ModeToSymbolTable[ModeName.HalfOperator]= '%';
			ModeToSymbolTable[ModeName.Voice]		= '+';
			ModeToSymbolTable[ModeName.Devoice]		= '-';
			// SymbolToModeTable inits
			SymbolToModeTable[ModeToSymbolTable[ModeName.Owner]]		= ModeName.Owner;
			SymbolToModeTable[ModeToSymbolTable[ModeName.Protected]]	= ModeName.Protected;
			SymbolToModeTable[ModeToSymbolTable[ModeName.Operator]]		= ModeName.Operator;
			SymbolToModeTable[ModeToSymbolTable[ModeName.HalfOperator]]	= ModeName.HalfOperator;
			SymbolToModeTable[ModeToSymbolTable[ModeName.Voice]]		= ModeName.Voice;
			SymbolToModeTable[ModeToSymbolTable[ModeName.Devoice]]		= ModeName.Devoice;
			// ModeToChar inits
			ModeToCharTable[ModeName.TopicOperatorOnly]  = 't';
			ModeToCharTable[ModeName.Registered]		 = 'r';
			ModeToCharTable[ModeName.Secret]			 = 's';
			ModeToCharTable[ModeName.NoExternalMessages] = 'n';
			ModeToCharTable[ModeName.Moderated]			 = 'm';
			ModeToCharTable[ModeName.Limit]				 = 'l';
			ModeToCharTable[ModeName.Key]				 = 'k';
			ModeToCharTable[ModeName.InviteOnly]		 = 'i';
			ModeToCharTable[ModeName.Private]			 = 'p';
			ModeToCharTable[ModeName.HiddenHostmask]	 = 'x';
			// CharToMode inits
			CharToModeTable[ModeToCharTable[ModeName.TopicOperatorOnly]]  = ModeName.TopicOperatorOnly;
			CharToModeTable[ModeToCharTable[ModeName.Registered]]		  = ModeName.Registered;
			CharToModeTable[ModeToCharTable[ModeName.Secret]]			  = ModeName.Secret;
			CharToModeTable[ModeToCharTable[ModeName.NoExternalMessages]] = ModeName.NoExternalMessages;
			CharToModeTable[ModeToCharTable[ModeName.Moderated]]		  = ModeName.Moderated;
			CharToModeTable[ModeToCharTable[ModeName.Limit]]			  = ModeName.Limit;
			CharToModeTable[ModeToCharTable[ModeName.Key]]				  = ModeName.Key;
			CharToModeTable[ModeToCharTable[ModeName.InviteOnly]]		  = ModeName.InviteOnly;
			CharToModeTable[ModeToCharTable[ModeName.Private]]			  = ModeName.Private;
			CharToModeTable[ModeToCharTable[ModeName.HiddenHostmask]]	  = ModeName.HiddenHostmask;
		}
	}
}
